package com.accloud.service;

import com.accloud.cloudservice.ACObjectMarshaller;
import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;

public class ACDeviceMsg implements Serializable {
    private static final long serialVersionUID = 16777217;
    protected int code;
    protected byte[] content;
    protected String description;
    @Deprecated
    protected ACDeviceSecurityMode securityMode;

    public ACDeviceMsg() {
        this.securityMode = ACDeviceSecurityMode.DYNAMIC_ENCRYPTED;
    }

    public ACDeviceMsg(int code2, byte[] content2) {
        this();
        this.code = code2;
        this.content = content2;
    }

    public ACDeviceMsg(int code2, byte[] content2, String description2) {
        this(code2, content2);
        this.description = description2;
    }

    public ACDeviceMsg(int code2, ACObject object) {
        this();
        this.code = code2;
        try {
            this.content = ACObjectMarshaller.marshal(object);
        } catch (IOException e) {
        }
    }

    public ACDeviceMsg(int code2, ACObject object, String description2) {
        this(code2, object);
        this.description = description2;
    }

    public void setSecurityMode(ACDeviceSecurityMode securityMode2) {
        this.securityMode = securityMode2;
    }

    public ACDeviceSecurityMode getSecurityMode() {
        return this.securityMode;
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(int code2) {
        this.code = code2;
    }

    public byte[] getContent() {
        return this.content;
    }

    public void setContent(byte[] content2) {
        this.content = content2;
    }

    public void setObject(ACObject object) {
        try {
            this.content = ACObjectMarshaller.marshal(object);
        } catch (IOException e) {
            System.out.println("object[" + object.toString() + "] marshal to content error[" + e.toString() + "]");
        }
    }

    public ACObject getObject() {
        ACObject object = new ACObject();
        try {
            ACObjectMarshaller.unmarshal(object, this.content);
        } catch (IOException e) {
            System.out.println("content[" + new String(this.content) + "] unmarshal to ACObject error[" + e.toString() + "]");
        }
        return object;
    }

    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description2) {
        this.description = description2;
    }

    @Override // java.lang.Object
    public String toString() {
        return "ACDeviceMsg{code=" + this.code + ", content=" + Arrays.toString(this.content) + ", description='" + this.description + "'}";
    }
}
